home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / bccapp.zip / ERROR.C < prev    next >
C/C++ Source or Header  |  1991-09-15  |  1KB  |  85 lines

  1. /*
  2.  *
  3.  * Critical RUN-Time error handling systems.
  4.  *
  5.  * (C) 1990 Vision Software
  6.  *
  7.  * $Id: error.c 1.2001 91/04/25 15:07:54 pcalvin release $
  8.  *
  9.  * Comments:
  10.  *
  11.  * Handles Fatal Errors and Run-Time asserts throughout the library.
  12.  *
  13.  * Bugs:
  14.  *
  15.  * What if we assert here??
  16.  *
  17.  */
  18. #include <iostream.h>
  19. #include <conio.h>
  20. #include <stdlib.h>
  21. #include <stdio.h>
  22. #include <stdarg.h>
  23.  
  24. #include <stdhdr.h>
  25.  
  26. #include <adl.h>
  27. #include <menu.h>
  28.  
  29. /*
  30.  * Fatal Errors..
  31.  */
  32. STATIC ENT pentFatal[] = { {"Exit Program",0,0,0} };
  33.  
  34. STATIC VOID
  35. FatalError(SZ sz)
  36.     {
  37.     DIALOG dial(sz,1,pentFatal);
  38.  
  39.     dial.CentGet();
  40.  
  41.     exit(12);
  42.     }
  43.  
  44. /*
  45.  * Simple File/Line assert
  46.  */
  47. EXTERN VOID
  48. AssertFailed(CL cl,SZ szFile)
  49.     {
  50.     SZTEMP sz;
  51.  
  52.     sprintf(sz,"Assertion Failed: %s, line %d",szFile,cl);
  53.  
  54.     FatalError(sz);
  55.     }
  56.  
  57. /*
  58.  * Provides more information to the user
  59.  */
  60. EXTERN VOID
  61. AssertFailedSz(CL cl,SZ szFile,SZ szMessage)
  62.     {
  63.     SZTEMP sz;
  64.  
  65.     sprintf(sz,"Assertion Failed: %s: %s, line %d",szMessage,szFile,cl);
  66.  
  67.     FatalError(sz);
  68.     }
  69.  
  70. /*
  71.  * IO errors..
  72.  */
  73. EXTERN VOID
  74. IOError(SZ szFormat,...)
  75.     {
  76.     SZTEMP sz;
  77.     va_list args;
  78.  
  79.     va_start(args,szFormat);
  80.     vsprintf(sz,szFormat,args);
  81.     va_end(args);
  82.  
  83.     FatalError(sz);
  84.     }
  85.